/**
 * 订单相关接口 
 */
var request = require('./request.js');
module.exports = {
  /**
   * 获取订单状态
   */
  getStatusCount: function () {
    return request.get('/newretail/api/mall/order/getStatusCount')
  },
  /**
   * 根据状态分页查询订单
   * @param page 当前页码，起始于1
   * @param pageSize 每页记录数，必须大于等于0且小于等于100，等于0时表示不分页查询全部数据， 大于0时表示分页查询
   * @param memberIdEquals 会员标识
   */
  query: function (postData) {
    return request.get('/newretail/api/mall/order/query', postData)
  },
  // query: function (postData) {
  //   return request.get('/newretail-search/api/search/order/query', postData)
  // },
  /**
   * 创建订单
   */
  create: function (postData) {
    return request.post('/newretail/api/mall/order/create', postData);
  },
  /**
   * 创建订单
   */
  createCatering: function (postData) {
    return request.post('/newretail/api/catering/order/create', postData);
  },
  /**
   * 创建抢购活动订单
   */
  createSecKill: function (postData) {
    return request.post('/newretail/api/mall/order/grab/create', postData);
  },
  /**
   * 获得对应的的支付订单签名
   */
  getPaySign: function (postData) {
    return request.post('/newretail/api/mall/order/getPaySign', postData);
  },
  /**
   * 查询订单详情
   * 根据订单标识查询具体订单详情
   *  @param orderId 订单Id
   */
  getDetailsById: function (orderId) {
    var params = {
      orderId: orderId
    }
    return request.get('/newretail/api/mall/order/getDetailsById', params)
  },
  /**
   * 根据订单标识查询具体订单状态
   * @param orderId 订单Id
   */
  getOrderStatusById: function (orderId) {
    var params = {
      orderId: orderId
    }
    return request.get('/newretail/api/mall/order/getOrderStatusById', params)
  },
  /**
   * 取消订单
   */
  cancel: function (orderId) {
    return request.put('/newretail/api/mall/order/cancel?orderId=' + orderId)
  },
  /**
   * 确认订单
   */
  confirm: function (orderId) {
    return request.put('/newretail/api/mall/order/confirm?orderId=' + orderId)
  },
  /**
   * 创建退款订单
   * @param applyReason 退款理由
   * @param orderId 商品订单Id
   */
  createRefund: function (postData) {
    return request.post('/newretail/api/mall/refund/create', postData);
  },
  /**
   * 获取与订单关联的退款单
   * @param orderId 商品订单Id
   */
  getByOrder: function (orderId) {
    var params = {
      orderId: orderId
    }
    return request.get('/newretail/api/mall/refund/getByOrder', params)
  },
  /**
   * 查询退款订单
   * @param page 当前页码，起始于1
   * @param pageSize 每页记录数，必须大于等于0且小于等于100，等于0时表示不分页查询全部数据， 大于0时表示分页查询
   * @param orderId 订单Id等于
   */
  queryRefund: function (page, pageSize, orderId) {
    var params = {
      page: page,
      pageSize: pageSize,
      orderId: orderId
    }
    return request.get('/newretail/api/mall/refund/query', params)
  },

  /**
   * 根据快递单号和快递公司查询具体的快递信息
   * @trackingCompany 快递公司 顺丰shunfeng,申通shentong,圆通yuantong,中通zhongtong,huitongkuaidi,韵达yunda,宅急送zhaijisong, 德邦物流debangwuliu
   *                  Available values : KUAIFUWU, SHUNFENG, SHENTONG, YUANTONG, ZHONGTONG, HUITONGKUAIDI, YUNDA, ZHAIJISONG, DEBANGWULIU, OTHER
   * @trackingNumber 快递单号
   */
  getOrderShipDetails: function (trackingCompany, trackingNumber) {
    var params = {
      trackingCompany: trackingCompany,
      trackingCompany: trackingNumber
    }
    return request.get('/api/newretail/api/mall/order/getOrderShipDetails', params)
  },
  /**
   * 创建积分商城订单
   */
  createScoreOrder: function (postData) {
    return request.post('/newretail/api/mall/order/createScoreOrder', postData);
  },
  /**
   * 储值卡支付
   * @param {object} postData
   * {
   *    orderId 订单标识;
   *    password 储值卡密码
   * } 
   */
  cardPay: function (postData) {
    return request.post('/newretail/api/mall/order/cardPay', postData);
  },

  /**
   * 储值卡预支付接口,该接口会为订单生成一笔待支付的储值支付明细,支付金额为会员的支付余额,待在线支付回调后,进行支付
   * @param {number} cardAmount 储值卡使用金额,组合支付时需要传入
   * @param {string} orderId 订单标识
   * @param {string} password 储值卡密码
   */
  prepareCardPay: function (postData) {
    return request.post('/newretail/api/mall/order/prepareCardPay', postData);
  },

  /**
   * 订单上锁
   */
  orderLock: function (orderId) {
    let params = {
      orderId: orderId
    }
    return request.post('/newretail/api/mall/order/orderLock', params);
  },

  /**
   * 获取当前会员的收货地址信息
   * @param {string} orderId 订单Id
   */
  getRideLocation: function (orderId) {
    let params = {
      orderId: orderId
    }
    return request.get('/newretail/api/mall/delivery/getRideLocation', params);
  },

  /**
   * 获取当前订单自动取消时间
   */
  getAutoCancelPeriod: function () {
    return request.get('/newretail/api/mall/order/getAutoCancelPeriod');
  },
}